package com.liang.threaddemo8;

public class Cookie extends Thread{


    @Override
    public void run() {
        while (true) {
            synchronized (Desk.obj) {
                if (Desk.count <= 0) {
                    break;
                }else{
                    if (Desk.flag) {
                        try {
                            Desk.obj.wait();
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                    }else{
                        System.out.println(Thread.currentThread().getName()+"正在做汉堡包");
                        Desk.flag = true;
                        Desk.obj.notify();
                    }
                }
            }
        }
    }
}
